package com.itheima.capsulation;

public class VerifyCodeUtil {
    //工具类没有创建对象的必要性，建议私有化构造器
    private VerifyCodeUtil() {
    }

    public static String getVerifyCode(int n) {
        String code = "";
        for (int i = 0; i < n; i++) {
            int type = (int) (Math.random() * 3);//0 1 2
            switch (type) {
                case 0://随机生成0-9
                    int num =(int) (Math.random() * 10);
                    code += num;
                    break;
                case 1:
                    char num1 =(char)( (int) (Math.random() * 26) + 'a');
                    code += num1;
                    break;
                case 2:
                    char num2 = (char)((int)(Math.random() * 26) + 'A');
                    code += num2;
                    break;
            }
        }
        return code;
    }
}
